package ObjectOutputStream_;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author feng
 * @Date 2021/12/27 11:08
 */
public class ObjectStream {
    public static void main(String[] args) throws IOException {
        String path = "D:\\IO\\data.dat";
        ObjectOutputStream oos = null;
        try {
            oos = new ObjectOutputStream(new FileOutputStream(path));
            oos.write(100);
            oos.writeBoolean(true);
            Dog xiao = new Dog("小", "red");
            oos.writeObject(xiao);
            System.out.println("写入成功");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            oos.close();
        }

    }
}

